function Sequence1211(view) {
	this.view = view;
}

Sequence1211.prototype.check = function(previous, toCheck) {
	return this.nextSequence(previous) == toCheck;
};

Sequence1211.prototype.nextSequence = function(previous) {
	return new SequenceGenerator().nextSequence(previous);
};

Sequence1211.prototype.startup = function(previous) {
	this.view.init(this);
};

function SequenceGenerator() {
}

SequenceGenerator.prototype.nextSequence = function(previous) {
	var newSequence = '';
	var currentSymbol = previous.charAt(0);
	var count = 1;

	for ( var i = 1; i < previous.length; i++) {
		if (previous.charAt(i) != currentSymbol) {
			newSequence += (count + currentSymbol);
			count = 0;
			currentSymbol = previous.charAt(i);
		}
		count++;
	}

	newSequence += (count + currentSymbol);

	return newSequence;
};